<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north'" style=" height:65px;padding:5px; border-top:0;border-left:0;border-right:0; overflow:hidden">
        <div style="float:left; padding:4px 0 0;">
        	<div style="margin:5px;font-size:15px;font-weight: 700;">名称：<?php echo $contentview[0]->run_title;?></div> 
            <div style="margin:5px;font-size:12px; float:left;">流水号：<?php echo $contentview[0]->run_id;?></div>             
            <div style="margin:5px;font-size:12px; float:left;">发起人：<?php echo $contentview[0]->begin_username;?></div> 
            <div style="margin:5px;font-size:12px; float:left;">发起时间：<?php echo $contentview[0]->begin_datetime;?></div> 
        </div>        
    </div>
    <div data-options="region:'south'" style="height:45px;padding:5px;border-left:0;border-right:0; border-bottom:0;">
    	<div style="float:left; padding:4px 0 0;">
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-arrow-down'" onclick="dialog_public('流程步骤','workflow/flow_chart/<?php echo $contentview[0]->run_id;?>')">第<?php echo $contentview[0]->ps_id;?>步</a>
        </div>
        <div style="float:right; padding:4px 0 0;">
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-arrow-down'" onclick="dialog_public('选择下一步办理人','workflow/flow_next/<?php echo $contentview[0]->run_id.'/'.$contentview[0]->ps_id.'/'.rawurlencode($contentview[0]->run_title);?>','700')">转交下一步</a>
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-accept'" onclick="flow_end('<?php echo $contentview[0]->run_id;?>','<?php echo $contentview[0]->ps_id;?>','<?php echo $contentview[0]->run_title;?>')">结束流程</a>
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-back'" onclick="$('#main-tab').tabs('select', '工作流')">返回</a>
        </div>
    
    </div>
    <div data-options="region:'east',split:true,collapsed:true" title="工作流登记单" style="width:300px;border-right:0;"></div>
    <div data-options="region:'center'" style="padding:20px;border-left:0;border-right:0; ">    	
        <div id="att_list_box_<?php echo $contentview[0]->run_id;?>"><?php echo $attlist;?></div>        
        <div style="margin:5px;font-size: 12px; font-family:'Microsoft Yahei'; position:relative">
            <div style="float:left; position:absolute; margin-left:90px;">
        		<a class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-folder'" onclick="dialog_public('文件柜','file_cabinets/select_filebox_out/workflow')">个人文件柜</a>
        	</div>
            <div style="float:left;"><input id="workflow_file_upload_<?php echo $contentview[0]->run_id;?>" name="workflow_file_upload_<?php echo $contentview[0]->run_id;?>" type="file" multiple></div>
            
            <script type="text/javascript">

            var fileList_workflow = new Array();
                <?php $timestamp = time();?>
                $(function() {
                    $('#workflow_file_upload_<?php echo $contentview[0]->run_id;?>').uploadify({
                        'height'          : 24,
                        'width'           : 80,
                        'buttonText'      : '上传附件',
                        'removeTimeout'	  : 0,
                        'fileTypeDesc'    : '所有文件',
                        'fileTypeExts'    : '*.*',
						//'fileTypeExts'	  : '<?php echo $this->attachment_type_str;?>',
						'fileSizeLimit'   : '<?php echo $this->attachment_size;?>',
                        'swf'             : '<?php echo base_url().'data/uploadify/uploadify.swf'?>',
                        'uploader'        : '<?php echo base_url().'attachment/upload'?>',
                        'formData' : {
                            'attdir'    : 'workflow',
                            'timestamp' : '<?php echo $timestamp;?>',
                            'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
                        },
                        'onUploadSuccess' : function(file, data, response) {
							var obj = eval('(' + data + ')'); 
							if(obj.flag){
								file.daterand = obj.str;
								file.name = obj.file_name;
								fileList_workflow.push(file);
							}else{
								alert(obj.str);
							}
							
                            //file.daterand = data;
                            //fileList_workflow.push(file);
                        },
                        'onQueueComplete' : function(queueData) {
                            //如果文件已经上传（即fileInfo不为空）
							
                            $.post("<?php echo base_url().'workflow/flow_att_update'?>",{
                                data:JSON.stringify(fileList_workflow),
                                id:'<?php echo $contentview[0]->run_id;?>'
                            },function(data,status){
                                if(data.success){
									$("#att_list_box_<?php echo $contentview[0]->run_id;?>").load('<?php echo base_url('workflow/flow_transact');?>',{
										id:'<?php echo $contentview[0]->run_id;?>',
										ps_id:'<?php echo $contentview[0]->ps_id;?>',
										is_v:0
									},function(responseTxt,statusTxt,xhr){
										if(statusTxt=="success"){
											bing_eattl_fun('<?php echo 'workflow'.$contentview[0]->run_id;?>');//重新渲染附件列表和右键事件
										}
										if(statusTxt=="error")
											alert("Error: "+xhr.status+": "+xhr.statusText);
									});
                                }
                            },'JSON');	
							fileList_workflow = new Array();//上传完一批后重新初始化fileList变量
                        },
                        'onCancel' : function(file) {
							$.messager.alert('提示','文件 ' + file.name + ' 被取消。','info');
							//alert('文件 ' + file.name + ' 被取消.');
						},
						'onSelectError': function (file, errorCode, errorMsg) {  
							switch (errorCode) {  
								case -100:  
									$.messager.alert('提示','上传的文件数量已经超出系统限制的' + $('#workflow_file_upload_<?php echo $contentview[0]->run_id;?>').uploadify('settings', 'queueSizeLimit') + '个文件！','info');
									//alert("上传的文件数量已经超出系统限制的" + $('#file_upload').uploadify('settings', 'queueSizeLimit') + "个文件！");  
									break;  
								case -110:  
									$.messager.alert('提示','文件 [' + file.name + '] 大小超出系统限制的' + $('#workflow_file_upload_<?php echo $contentview[0]->run_id;?>').uploadify('settings', 'fileSizeLimit') + ' 大小！','info');
									//alert("文件 [" + file.name + "] 大小超出系统限制的" + $('#file_upload').uploadify('settings', 'fileSizeLimit') + "大小！");  
									break;  
								case -120:  
									$.messager.alert('提示','文件 [' + file.name + '] 大小异常！','info');
									//alert("文件 [" + file.name + "] 大小异常！");  
									break;  
								case -130:  
									$.messager.alert('提示','文件 [' + file.name + '] 类型不正确！','info');
									//alert("文件 [" + file.name + "] 类型不正确！");  
									break;  
							}  
							return false;  
						},
						'onFallback': function () {  
							$.messager.alert('提示','您未安装FLASH控件，无法上传！请安装FLASH控件后再试。','info');
							//alert("您未安装FLASH控件，无法上传！请安装FLASH控件后再试。");  
						}
                    });
                });

            </script>
        </div>
    </div>
</div>
<script>

function setworkflow_att_obj(m,id,name,size){
	if(id.length > 0){
		//alert(name);
		//删除最后一个逗号
		id=id.substring(0,id.length-1);
		size=size.substring(0,size.length-1);
		name=name.substring(0,name.length-1);
		
		//把附件的ID和名称按分隔符分割为数组
		var ids= new Array(); //定义一数组 
			ids=id.split(","); //字符分割 
		var sizes= new Array(); //定义一数组 
			sizes=size.split(","); //字符分割 
		var names= new Array(); //定义一数组 
			names=name.split("*"); //字符分割 
		
		//循环赋值给fileList数组
		for (i=0;i<ids.length ;i++ ){ 
			//var att_arr=id[i].split("_"); //分割日期_文件随机码_分解大小字符，以备显示文件大小
			var att_files = {};//清空
			att_files = {
					'daterand': ids[i], //属性名用引号括起来，属性间由逗号隔开
					'name': names[i],
					'size': sizes[i]
				};			
			fileList_workflow.push(att_files);
			//var attsize = size;//所有附件的和
		}
		$.post("<?php echo base_url().'workflow/flow_att_update'?>",{
			data:JSON.stringify(fileList_workflow),
			id:'<?php echo $contentview[0]->run_id;?>'
		},function(data,status){
			if(data.success){
				$("#att_list_box_<?php echo $contentview[0]->run_id;?>").load("<?php echo base_url('workflow/flow_transact');?>",{
					id:<?php echo $contentview[0]->run_id;?>,
					ps_id:<?php echo $contentview[0]->ps_id;?>,
					is_v:0				
				},function(responseTxt,statusTxt,xhr){
					if(statusTxt=="success"){
						bing_eattl_fun('<?php echo 'workflow'.$contentview[0]->run_id;?>');//重新渲染附件列表和右键事件
					}
					if(statusTxt=="error")
						alert("Error: "+xhr.status+": "+xhr.statusText);
				});
			}
		},'JSON');	
		fileList_workflow = new Array();//上传完一批后重新初始化fileList变量
	}
	
}


//重新渲染附件列表和右键事件
bing_eattl_fun('<?php echo 'workflow'.$contentview[0]->run_id;?>');//参数为面板的拼接ID

</script>

